﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web.Http;

using API.Models;
using API.Models.Repository;

namespace API.Controllers.api.v1
{
    public class ITEMS_MAPPINGController : BasicController
    {
        public IEnumerable<ITEMS_MAPPING> Get(Guid COMPANY_GUID, Guid ITEM_GUID)
        {
            var repository = new ITEMS_MAPPING_Repository();
            repository.SetSession(this.currentSession);

            return repository.GetMapping(COMPANY_GUID, ITEM_GUID);
        }

        public void Post(ITEM_MAP item)
        {
            var repository = new ITEMS_MAPPING_Repository();
            repository.SetSession(this.currentSession);

            repository.SetMapping(item.LEFT_ITEM_GUID, item.RIGHT_ITEM_GUID);
        }

        [HttpGet]
        public IEnumerable<ITEM_COMPANY> GetUnbinding()
        {
            var repository = new ITEMS_MAPPING_Repository();
            repository.SetSession(this.currentSession);

            return repository.GetUnbinding();
        }

        [HttpGet]
        public ITEM_COMPANY_MAP GetBinding(Guid id)
        {
            var repository = new ITEMS_MAPPING_Repository();
            repository.SetSession(this.currentSession);

            return repository.GetMapping(id);
        }
    }
}
